import { DD_SYSTEM } from '@/constants/api-pre';
import { request } from '@/service/request';

/** log login */
export type LogLogin = Api.Common.CommonRecord<{
  logType: number;
  traceId: string;
  userId: number;
  userType: number;
  username: string;
  result: number;
  loginLocation: string;
  userIp: string;
  browser: string;
  os: string;
}>;

/** log login search params */
export type LogLoginSearchParams = CommonType.RecordNullable<
  Pick<LogLogin, 'username' | 'userIp'> &
    Api.Common.CommonSearchParams & {
      createTime: null;
    }
>;
/** log login list */
export type LogLoginList = Api.Common.PaginatingQueryRecord<LogLogin>;

/** fetch log login list */
export function fetchGetLogLoginList(params?: LogLoginSearchParams) {
  return request<LogLoginList>({
    url: `${DD_SYSTEM}/login-log/page`,
    method: 'get',
    params
  });
}
